import Form from '../packages/form'
import Button from '../packages/button'
import Table from '../packages/table'
import Anchor from '../packages/anchor'
import Dialog from '../packages/dialog'
import Draggable from '../packages/draggable'
import Layout from '../packages/layout'
import Tree from '../packages/tree'
import { addDicts } from './mixins/dict'
import { setRule } from './mixins/rule'

function install(Vue, options = {}) {
  const { dicts, rules } = options
  dicts && addDicts(dicts)
  rules && setRule(setRule)
  for (const component of Object.values(components)) {
    Vue.use(component)
  }
}

const components = {
  Table,
  Button,
  Anchor,
  Form,
  Dialog,
  Draggable,
  Layout,
  Tree
}

export default { ...components, install }
